package com.hzh.spark.core

import org.apache.spark.{SparkConf, SparkContext}

object Demo14mapValues {
  def main(args: Array[String]): Unit = {
    /**
     * 建立连接
     */

    val conf = new SparkConf()
    conf.setMaster("local")
    conf.setAppName("Demo13Sort")
    val sc = new SparkContext(conf)

    sc.textFile("data/score.txt")
      .map(_.split(","))
      .filter(_.length == 3)
      .map {
        case Array(sid: String, _: String, sco: String) =>
          (sid, sco.toInt)
      }
      .reduceByKey(_ + _)
      .mapValues(_/10)
      .foreach(println)
  }

}
